<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%--
  Created by IntelliJ IDEA 14.1.6
  User: LiShixi
  Date: 2016/7/23 0023
  Time: 21:35

--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <script src="js/angular-1.0.8/angular.js"></script>
    <script src="js/angular-1.0.8/angular-route.min.js"></script>
    <script type="text/javascript">
        function loginController($scope, $http) {
            $scope.userid = "admin";
            $scope.passwd = "admin";
            $scope.userType="0";
            $scope.msg = "";
            $scope.login = function () {
                $http({
                    method: "post",
                    url: 'librarian/login.do',
                    params: {"userid": $scope.userid, "passwd":$scope.passwd,"userType":$scope.userType}
                }).success(function (data, status, headers, config) {
                            $scope.msg = data;
                            window.location.href=data;
                        }).error(function (data, status, headers, config) {
                    alert("error" + data);

                })
            }

        }
    </script>

    <style>
        form {
            padding: 4px;
        }
    </style>
</head>
<body style="text-align: center" ng-app>

<div ng-controller="loginController">
    <div><h1>图书管理系统</h1></div>
    <div id="msg">
        <label ng-bind="msg"/>
    </div>

    <form action="librarian/login.do" method="post">
        <input type="radio" name="userType" id="rdo-admin" ng-model="userType" ng-checked="true" value="0"><label for="rdo-admin">管理员</label>
        <input type="radio" name="userType" id="rdo-reader"  ng-model="userType"   value="1"> <label for="rdo-reader" >读者</label><br>
        用户:<input type="text" name="userid" ng-model="userid" value="admin"> <BR>
        密码:<input type="password" name="passwd" ng-model="passwd" value="admin"/> <BR>
        <input type="button" value="登录" ng-click="login()"/><input type="reset">
    </form>
</div>
</body>
</html>
